package com.learn.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import com.learn.service.SysUserService;
import com.learn.dao.StudyDao;
import com.learn.entity.StudyEntity;
import com.learn.service.StudyService;



@Service("studyService")
public class StudyServiceImpl implements StudyService {
	@Autowired
	private StudyDao studyDao;

    @Autowired
    private SysUserService sysUserService;
	
	@Override
	public StudyEntity queryObject(Long id){
			StudyEntity entity = studyDao.queryObject(id);

						            if (this.sysUserService.queryObject(entity.getUser()) != null)
                entity.setSysUserEntity(this.sysUserService.queryObject(entity.getUser()));
												
		return entity;
	}
	
	@Override
	public List<StudyEntity> queryList(Map<String, Object> map){
        List<StudyEntity> list = studyDao.queryList(map);
        for(StudyEntity entity : list){
            if (this.sysUserService.queryObject(entity.getUser()) != null)
                entity.setSysUserEntity(this.sysUserService.queryObject(entity.getUser()));
		}
		return list;
	}
	
	@Override
	public int queryTotal(Map<String, Object> map){
		return studyDao.queryTotal(map);
	}
	
	@Override
	public void save(StudyEntity study){
		studyDao.save(study);
	}
	
	@Override
	public void update(StudyEntity study){
		studyDao.update(study);
	}
	
	@Override
	public void delete(Long id){
		studyDao.delete(id);
	}
	
	@Override
	public void deleteBatch(Long[] ids){
		studyDao.deleteBatch(ids);
	}
	
}
